# _*_ coding：UTF-8 _*_
# 开发人员：lgm
# 开发时间：2021/6/17 11:32
# 文件名称：NO_1.PY
# 开发工具：PyCharm
import time
from random import randint
from selenium.webdriver.common.by import By
ti_sum1 = 20
ti_sum2 = 35
ti_sum3 = 40

ti_list1 = []
ti_list2 = []
ti_list3 = []
class StartOj1:
    def __init__(self,driver):
        self.driver = driver

    def diyixiang(self):
        self.driver.find_element(By.XPATH, "/html/body/div[2]/div/div/ul[1]/li[1]").click()

        time.sleep(1)
        for i in range(3):
            nub = randint(1, 2)

            self.driver.find_element_by_xpath("/html/body/div[2]/div[2]/div/ul/li[" + str(i + 1) + "]/div[1]/label[" + str(nub) + "]/span[2]").click()
            if nub == 1:
                ti_list1.append("5")
            else:
                ti_list1.append("0")
        self.driver.find_element_by_xpath("/html/body/div[2]/div[2]/div/ul/li[4]/div/div/ul/li[3]").click()
        ti_list1.append("2")

        #第二项
        self.driver.find_element(By.XPATH, "/html/body/div[2]/div[3]/p").click()
        self.driver.implicitly_wait(20)
        time.sleep(2)
        for i in range(6):
            nub = randint(1, 2)
            self.driver.find_element_by_xpath(
                "/html/body/div[2]/div[3]/div/ul/li[" + str(i + 1) + "]/div[1]/label[" + str(nub) + "]/span[2]").click()
            if nub == 1:
                ti_list2.append("5")
            else:
                ti_list2.append("0")

        self.driver.find_element_by_xpath("/html/body/div[2]/div[3]/div/ul/li[7]/div/div/ul/li[5]").click()
        ti_list2.append("4")
        self.driver.find_element_by_xpath("/html/body/div[2]/div[4]/p").click()
        time.sleep(2)
        for i in range(8):
            nub = randint(1, 2)
            self.driver.find_element_by_xpath(
                "/html/body/div[2]/div[4]/div/ul/li[" + str(i + 1) + "]/div[1]/label[" + str(nub) + "]/span[2]").click()
            if nub == 1:
                ti_list3.append("5")
            else:
                ti_list3.append("0")

        t1_ac = 0
        for i in ti_list1:
            t1_ac += int(i)
        t1_aa = float(t1_ac) /float(ti_sum1)
        t1_result = t1_aa * 0.2272
        print("第一小节权重：", t1_result)
        print("第一小节得分明细：", ti_list1)

        t2_ac = 0
        for i in ti_list2:
            t2_ac += int(i)
        t2_aa = float(t2_ac) / float(ti_sum2)
        t2_result = t2_aa * 0.3467
        print("第二小节权重：", t2_result)
        print("第二小节得分明细：", ti_list2)
        t3_ac = 0
        for i in ti_list3:
            t3_ac += int(i)
        t3_aa = float(t3_ac) / (ti_sum3)
        t3_result = t3_aa * 0.4261
        print("第三小节权重：", t3_result)
        print("第三小节得分明细：", ti_list3)

        quanzhong = t1_result + t2_result + t3_result
        print("权重系数总和", quanzhong)
        t_result = int(round((t1_result + t2_result + t3_result) * 150,0))
        print("最后得分：", t_result)
        time.sleep(5)
        self.driver.find_element_by_xpath("/html/body/div[2]/input").click()
        time.sleep(2)
        d3_data = self.driver.find_element(By.XPATH, "/html/body/div[2]/div[1]/p").text
        result_data = d3_data.split(" ")
        xitong_fen = result_data[0]
        print("系统最总合计得分：", xitong_fen)
        self.driver.find_element(By.XPATH,"/html/body/div[2]/div[4]/input[2]").click()

        self.driver.implicitly_wait(20)
        return t_result,ti_list1,ti_list2,ti_list3